//
//  UserResumeViewController.m
//  XinKaiFa55like
//
//  Created by junseek on 2017/8/8.
//  Copyright © 2017年 55like lj. All rights reserved.
//

#import "UserResumeViewController.h"
#import "UserResumeViewTableViewCell.h"
#import "RHTableView.h"
#import "UserResumeContentViewController.h"

@interface UserResumeViewController ()<UISearchBarDelegate>{
    RHTableView *table_user;
    UISearchBar *mySearchBar;
    
}


@end

@implementation UserResumeViewController


-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.view endEditing:YES];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [self initComponents];
}
-(void)myResume{
    
    
    [self pushController:[UserResumeViewController class] withInfo:@"1" withTitle:@"我的简历" withOther:nil];
    
    
}
- (void)initComponents{
    
    if (![self.userInfo isEqualToString:@"1"]) {
        [self rightButton:@"我的简历" image:nil sel:@selector(myResume)];
    }
    
    
    UIView *viewSearchBtnBg=[[UIView alloc] initWithFrame:CGRectMake(0, kTopHeight, kScreenWidth, 44)];
    [self.view addSubview:viewSearchBtnBg];
    viewSearchBtnBg.backgroundColor=rgbGray;
    
    
    mySearchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(10, 7, kScreenWidth-20, 30)];
    mySearchBar.delegate = self;
    mySearchBar.placeholder=@"同事姓名/部门名称";
    [viewSearchBtnBg addSubview:mySearchBar];
    [mySearchBar setBackgroundImage:[[Utility Share] imageFromColor:[UIColor whiteColor] rect:CGSizeMake(kScreenWidth-20, 30)]];
    [mySearchBar setBackgroundColor:[UIColor whiteColor]];
//    [mySearchBar viewLayerRoundBorderWidth:0.5 cornerRadius:4.0 borderColor:rgbLineColor];
    [[Utility Share] viewLayerRound:mySearchBar borderWidth:0.5 cornerRadius:4 borderColor:rgbLineColor];
    [viewSearchBtnBg addSubview: [RHMethods lineViewWithFrame:CGRectMake(0, 43.5, kScreenWidth, 0.5)]];
    
    
    
    table_user=[[RHTableView alloc]initWithFrame:CGRectMake(0, YH(viewSearchBtnBg), kScreenWidth, kContentHeight-H(viewSearchBtnBg))];
    [table_user showRefresh:YES LoadMore:YES];
    table_user.delegate = self;
    table_user.dataSource = self;
    [table_user setBackgroundColor:rgbGray];
    [table_user setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    [self.view addSubview:table_user];
    [table_user registerClass:[UserResumeViewTableViewCell class] forCellReuseIdentifier:@"UserResumeViewTableViewCell"];
    [table_user setAutoresizingMask:UIViewAutoresizingFlexibleHeight];
    table_user.rowHeight=105;
    
    if ([self.userInfo isEqualToString:@"1"]) {
        
        table_user.frameY = 64;
        
    }
    [self loadRightTableData:@""];
    
}

-(void)loadRightTableData:(NSString *)keyStr{
    krequestParam
    [dictparam setValue:@"%@" forKey:@"page"];
    [dictparam setValue:@"20" forKey:@"pagesize"];
    [dictparam setValue:keyStr forKey:@"key"];
    [dictparam setValue:self.userInfo forKey:@"type"];
    table_user.urlString=[NSString stringWithFormat:@"%@%@",XKFV4customerarchives_lists,dictparam.wgetParamStr];
    [table_user refresh];
}


#pragma mark button


#pragma mark tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return table_user.dataArray.count;
    
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSDictionary *dic =[table_user.dataArray objectAtIndex:indexPath.row];
    UserResumeViewTableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:@"UserResumeViewTableViewCell" forIndexPath:indexPath];
    [cell setValueForDictionary:dic indexPath:indexPath type:@"myGroup"];
    [cell setSelectionStyle:UITableViewCellSelectionStyleNone];
    return cell;
    
    
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    NSDictionary *dic =[table_user.dataArray objectAtIndex:indexPath.row];
    [self pushController:[UserResumeContentViewController class] withInfo:@"" withTitle:@"简历详情" withOther:dic];
}
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView{
    [mySearchBar resignFirstResponder];
}
#pragma mark UISearchBarDelegate
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText
{//
   
     [self loadRightTableData:searchText];
}

-(void)searchBarSearchButtonClicked:(UISearchBar *)searchBar{
    [self loadRightTableData:searchBar.text];
    [searchBar resignFirstResponder];
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
